const domainName = getApp().globalData.domainName
const parameter = getApp().globalData.parameter

// pages/gs/dji/dji.js
const jg_stu_id = wx.getStorageSync('jg_stu_id')
const user_id = wx.getStorageSync('user_id')
Page({

  /**
   * 页面的初始数据
   */
  data: {
    windowWidth:wx.getSystemInfoSync().windowWidth,
    last_video:'',
    last_book:{},
    gs_tis:[]
  },

  more_video(){
    getApp().get_vibration()
    if(this.can_gs!=1){
      wx.showModal({
        content: '您暂无权限',
        showCancel: false,
        title: '提示',
      })
      return 
    }
    wx.navigateTo({
      url: '/pages/video/video_library/video_library',
    })
  },

  more_book(){
    getApp().get_vibration()
    if(this.can_gs!=1){
      wx.showModal({
        content: '您暂无权限',
        showCancel: false,
        title: '提示',
      })
      return 
    }
    wx.navigateTo({
      url: '/pages/book/book_library/book_library',
    })
  },
  
  view_book(){
    getApp().get_vibration()
    wx.navigateTo({
      url: '/pages/book/book_show/book_show?url=' + this.data.last_book.url,
    })
  },

  gs_tis(e){
    getApp().get_vibration()
    if(this.can_gs!=1){
      wx.showModal({
        content: '您暂无权限',
        showCancel: false,
        title: '提示',
      })
      return 
    }
    let index = e.currentTarget.id
    wx.navigateTo({
      url: '/pages/gs/gs_doTi/gs_doTi?type_id=' + this.data.gs_tis[index].id,
    })
  },

  page_init(user_id, jg_stu_id){
    wx.showLoading()
    wx.request({
      url: domainName + '/gs_dji_init',
      data: {user_id,jg_stu_id},...parameter,
      success: res => {
        wx.hideLoading()
        // console.log('res',res.data)
        this.can_gs=res.data.can_gs
        this.setData({
          last_book:res.data.last_book,
          last_video:res.data.last_video,
          gs_tis:res.data.lis,
        })
      },
    })
  },


  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.setData({
      show_video:options.show_video,
    })
    this.page_init(user_id,jg_stu_id)
  },

})